﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Common;

namespace DataSetApp
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            DataGrid _dg = new DataGrid();
        }

        private void buttonAdd_Click(object sender, EventArgs e)
        {
            DataRow row = dataTableContacts.NewRow();
            row["Name"] = textBox1.Text;
            row["Last Name"] = textBox2.Text;
            dataTableContacts.Rows.Add(row);

        }

        private void buttonDelete_Click(object sender, EventArgs e)
        {
            try
            {
                dataTableContacts.Rows[dataGridView1.CurrentCell.RowIndex].Delete();
                dataTableContacts.AcceptChanges();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
